# Contributor: Josip <bpisoj@gmail.com>

_realname=osm-gps-map
pkgbase=mingw-w64-osmgpsmap-git
pkgname="${MINGW_PACKAGE_PREFIX}-osmgpsmap-git"
provides=("${MINGW_PACKAGE_PREFIX}-osmgpsmap")
conflicts=("${MINGW_PACKAGE_PREFIX}-osmgpsmap")
pkgver=r443.c24d08d
pkgrel=1
pkgdesc="A Gtk+ Widget for Displaying OpenStreetMap tiles"
url="https://nzjrs.github.io/osm-gps-map/"
arch=('any')
license=('GPLv2+')
depends=("${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-libsoup"
         "${MINGW_PACKAGE_PREFIX}-python2-gobject"
         "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
makedepends=("${MINGW_PACKAGE_PREFIX}-gnome-common"
             "gtk-doc"
             "git")
options=('staticlibs' 'strip' '!debug')
source=("git+https://github.com/nzjrs/osm-gps-map"
        001-fix-docdir.patch)
sha256sums=('SKIP'
            '2c6165602198b9e316a3cfa4b1692ad687045bf49bdace4117669f7c1c71744d')

pkgver() {
  cd ${_realname}
  printf 'r%s.%s' "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd ${_realname}
  patch -p1 -i ${srcdir}/001-fix-docdir.patch

  gtkdocize
  autoreconf -fiv
}

build() {
  export CC=${MINGW_PREFIX}/bin/gcc
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-gtk-doc=no \
    --enable-shared=yes \
    --enable-static=yes

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
